Binary Trees: Definitions and Properties
A Binary Tree (BT) is a hierarchical data structure where each node has at most two children: a left child and a right child. They are crucial for implementing efficient data storage, search algorithms, and representing computational structures like Abstract Syntax Trees (ASTs).
Key Types & Property
- Strict/Full Binary Tree: Every non-leaf node has exactly two children.
- Perfect Binary Tree: A full tree where all leaves are at the same level.
Crucial Node Relationship (Strict Binary Trees):
If is the total number of nodes, is the number of leaf nodes, and is the number of internal (non-leaf) nodes:
If a strict tree has 10 internal nodes (), it must have 11 leaf nodes (), totaling nodes.
Height and Node Capacity
The height () of a tree (maximum number of edges from the root to the deepest leaf) dictates its maximum capacity:
| Level (, Root=0) | Max Nodes | Total Max Nodes (Perfect Tree) |
|---|---|---|
| 0 (Root) | 1 | |
Optimal Height: For a tree with nodes, the minimum possible height (achieved by a balanced tree) is:
1. A programmer constructs a strict binary tree. If it has 15 non-leaf (internal) nodes, how many total nodes () does it contain?
2. Which property best describes a Perfect Binary Tree?
3. What is the maximum number of nodes in a perfect binary tree with a height of 3?
4. In a binary tree, what does the 'depth' of a node refer to?